package com.lagou.controller;

import com.lagou.domain.Tarticle;
import com.lagou.service.TarticleServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by shixi  on 2020/10/15
 */
@Controller
public class ArticleController {
    @Autowired
    private TarticleServiceImpl tarticleService;

    @RequestMapping("/index")
    public String indexPage(Model model, @RequestParam(value = "pageNum", defaultValue = "0",required = false) Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "2", required = false) Integer pageSize){

        System.out.println("pageNum:"+pageNum);
        System.out.println("pageSize:"+pageSize);
        Page<Tarticle> articles = tarticleService.pages(pageNum, pageSize);
        model.addAttribute("articles", articles);

        return "client/index";
    }
}
